﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SharingCenter.Web.Classes.Events;
using SharingCenter.Web.Classes;

namespace SharingCenter.Web.Admin.Events
{
    public partial class Default : System.Web.UI.Page
    {
        protected string type;
        protected void Page_Init(object sender, EventArgs e)
        {
            LinqDataSource1.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDataSource1_Selecting);
            type = Request.QueryString["type"] ?? "incoming";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!("incoming" == type))
            {
                GenericTabs1.SelectedItem = "2";
            }
        }

        void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            //e.WhereParameters["StartDate"] = DateTime.Now;
            scDataContext cxt = new scDataContext();
            if ("incoming" == type)
            {
                e.Result = from t in cxt.Sc_Events
                           where t.StartDate > DateTime.Now
                           select t;
            }
            else
            {
                e.Result = from t in cxt.Sc_Events
                           where t.StartDate < DateTime.Now || t.EndDate < DateTime.Now
                           select t;
            }
        }
    }
}